﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <div>
        <table class="easyui-datagrid" id="Messagelist" data-options="rownumbers:true">

        </table>

        <div id="messagerewin" class="easyui-dialog" title="添加" style="width: 200px; height: 90px;"
            data-options="iconCls:'icon-add',resizable:true,modal:true,closed: true">
            <div style="margin: 0 auto; text-align: center;">
                <form encType=multipart/form-data id="reform" method=post   action=/RoomManage/addMessage>
                     <input  type="text" id="rid" name="rid" style="display:none"  />
                    <input  type="text" id="rcontext" name="rcontext"  />
                    <input  type="submit" value="提交" />  
                </form>
            </div>
        </div>
    </div>
      <script type="text/javascript">
          $('#Messagelist').datagrid({
              url: '../admin/Getmessagelist',
              singleSelect: true,
              columns: [[
               { field: 'Name', title: '姓名', width: 200 },
                { field: 'addr', title: '地址', width: 70 },
                { field: 'email', title: '邮件地址', width: 70 },
                { field: 'context', title: '内容', width: 70 },
                { field: 'respuse', title: '回复内容', width: 200 },
                   {
                       field: 'opt', title: '删除操作', width: 100, align: 'center',
                       formatter: function (value, rec) {
                           var btn = "<a href=" + "#" + " class=" + "easyui-linkbutton" + " iconcls=" + "icon-edit" + " onclick=" + "DelMessage(" + rec.ID + ")" + " plain=" + "true" + ">删除</a>";
                           return btn;
                       }
                   }
                   ,
                   {
                       field: 'opt1', title: '回复操作', width: 100, align: 'center',
                       formatter: function (value, rec) {
                           var btn1 = "<a href=" + "#" + " class=" + "easyui-linkbutton" + " iconcls=" + "icon-edit" + " onclick=" + "reMessage(" + rec.ID + ")" + " plain=" + "true" + ">回复</a>";
                           return btn1;
                       }
                   }
              ]]
          });
          function DelMessage(id)
          {
              $.post("../Admin/delmessage", { ID: id },
               function (data) {
                   if (data == false) {
                       $.messager.alert('未知错误', '删除失败.');
                   }
                   else {
                       $.messager.alert('提示', '删除成功');
                       $('#dg').datagrid('load', {
                           code: '01',
                           name: 'name'
                       });
                   }
               });
          }
          function reMessage(id) {
              $('#rid').val = id;
              $('#messagerewin').dialog('open');
          }
       </script>
</body>
</html>
